package com.caiyi.financial.nirvana.sms.service;

import com.caiyi.financial.nirvana.sms.base.service.BaseService;
import com.caiyi.financial.nirvana.sms.entity.SmsGatewaySign;
import com.caiyi.financial.nirvana.sms.mapper.SmsGatewaySignMapper;
import com.caiyi.financial.nirvana.sms.querybean.GatewaySignQueryBean;
import com.caiyi.financial.nirvana.sms.querybean.PageBean;
import com.caiyi.financial.nirvana.sms.vo.SmsGatewaySignVo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SmsGatewaySignService extends BaseService<SmsGatewaySign> {

    @Autowired
    private SmsGatewaySignMapper smsGatewaySignMapper;


    public int addGatewaySign(SmsGatewaySign smsGatewaySign) {
        int insertCount = this.insertByEntitySelective(smsGatewaySign);
        return insertCount;
    }

    public int deleteGatewaySign(Integer id) {
        SmsGatewaySign smsGatewaySign = new SmsGatewaySign();
        smsGatewaySign.setId(id);
        int deleteCount = this.deleteByPrimaryKey(smsGatewaySign);
        logger.info("deleteByGatewaySignId id {}", id);
        return deleteCount;
    }

    public int updateGatewaySign(SmsGatewaySign smsGatewaySign) {
        int updateCount = this.updateByEntitySelective(smsGatewaySign);
        return updateCount;
    }

    public PageBean<SmsGatewaySignVo> getGatewaySignByParams(GatewaySignQueryBean bean) {
        PageHelper.startPage(bean.getPageNum(), bean.getPageSize());
        List<SmsGatewaySignVo> list = smsGatewaySignMapper.selectGatewaySignListByParams(bean);
        PageBean<SmsGatewaySignVo> pageBean = new PageBean<>(list);
        return pageBean;
    }

    public int updateStatus(Integer id) {
        int updateCount = smsGatewaySignMapper.changeStatus(id);
        return updateCount;
    }


}
